package adc.app.ui.wicket;

import java.io.Serializable;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.model.ResourceModel;

import adc.app.ui.wicket.security.AuthenticationRequired;

@AuthenticationRequired
public class ChangePasswordLink extends LabeledLinkPanel {
	
	private static final long serialVersionUID = 1L;

	public static interface IChangePasswordCallback extends Serializable {
		void onChangePassword(AjaxRequestTarget target);
	}
	
	private IChangePasswordCallback callback;
	
	public ChangePasswordLink(String id) {
		super(id, new ResourceModel(IMsgs.CHANGE_PASSWORD));
		this.setLink(new AjaxLink<Object>(this.getLinkId()) {

			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				if (callback != null) {
					callback.onChangePassword(target);
				}
			}
		});
	}

	public final IChangePasswordCallback getCallback() {
		return callback;
	}

	public final ChangePasswordLink setCallback(IChangePasswordCallback callback) {
		this.callback = callback;
		return this;
	}
}
